#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include "stdio.h"
#include "string.h"
#include <algorithm>
using namespace std;


int main()
{
	int sale[100];
	int num = 0;
	int chao5=0,chao10=0,chao20=0;
	vector<int>money;
	string s;

	// 含，的字符串输入
	cin>>s;
	char *str = (char *)s.c_str();
	const char *split = ",";
	char *p = strtok(str,split);
	int a;
	while(p!=NULL)
	{
		sscanf(p,"%d",&a);
		money.push_back(a);
		p = strtok(NULL,split);
	}

	num = money.size();

	if (money[0] !=5)
		cout <<"false,1"<<endl;
	else
	{
		sale[0] = 5;
		chao5++;

		for (int i=1; i<num;i++)
		{
			if (money[i] ==5)
			{
				if (i==num-1)
				{
					cout <<"true,"<<i+1<<endl;
				}
				chao5++;
			}

			if (money[i] ==10)
			{
				if  (chao5 == 0)
				{
					cout <<"false,"<<i+1<<endl;
					break;
				}
				else
				{
					if (i==num-1)
					{
						cout <<"true,"<<i+1<<endl;
					}
					chao10++;
					chao5--;
				}
			}
			
			if (money[i] ==20)
			{
				
				if (((chao10<1)||(chao5<1)) && (chao5<3)) 
				{
					cout <<"false,"<<i+1<<endl;
					break;
				}
				else
				{
					if (i==num-1)
					{
						cout <<"true,"<<i+1<<endl;
					}
					chao20++;
					if ((chao10<1)||(chao5<1))
					{
						chao5 = chao5-3;
					}
					else 
					{
						chao10--;
						chao5--;
					}
				}
			}
			sale[i] = chao5*5+chao10*10+chao20*20;

			if (((money[i] !=20) && (money[i] !=10)) && (money[i] !=5))
			{
				cout <<"false,"<<i+1<<endl;
				break;
			}

		}
	}
	
	system("pause");
    return 0;
}